<template>
	<view>
		<uni-nav-bar :border="false" :fixed="true" :statusBar="true">	
			<view class="uni-flex nav-bar-tab">
				<block v-for="(item, index) in tabBars" :key="item.id">
					<view @tap="changeTab(index)" :class="{ active: index === trendTabIndex }">
						{{ item.name }}
						<view class="nav-bar-tab-line"></view>
					</view>
				</block>
			</view>
		</uni-nav-bar>
	</view>
</template>

<script>
	import uniNavBar from '../../components/uni-nav-bar/uni-nav-bar.vue';
	import { mapState, mapMutations } from 'vuex';
	export default {
		computed:{
			...mapState(['trendTabIndex'])
		},
		props: {
			tabBars: Array
		},
		methods: {
			...mapMutations(['setTrendTabIndex']),
			changeTab(index) {
				this.setTrendTabIndex(index);
			}
		}
	};
</script>

<style lang="less" scoped>
	.uni-flex {
		justify-content: center;
		align-items: center;
		flex: 1;
	}
	
	.nav-bar-tab {
		width: 100%;
		margin: -20rpx;
		position: relative;
		& > view:last-child {
			padding-left: 26rpx;
		}
		view {
			display: flex;
			flex-direction: row;
			justify-content: center;
			align-items: center;
			font-size: 36rpx;
			
			color: #969696;
		}
		.active {
			color: #333333;
			font-weight: 700;
			.nav-bar-tab-line {
				position: absolute;
				bottom: 5rpx;
				border-top: 5rpx solid #feb7ba;
				border-bottom: 5rpx solid #feb7ba;
				width: 70rpx;
				border-radius: 20rpx;
			}
		}
	}
</style>
